/*

	Logger.h
	
	Logger class used for logging various
	messages, warnings and errors at run
	time. Contains functionality for writing
	log entries to a text file.
	
	Written by Sigurd Suhm 2009

*/

#ifndef _LOGGER_H
#define _LOGGER_H

// Includes
#include <string>		// C++ string type header
#include <vector>		// STL vector class header

namespace EraAstral
{
	namespace core
	{
		// Log type enumerator
		typedef enum
		{
			// Plain message
			LE_MESSAGE = 0,
			// Warning - Possible error
			LE_WARNING,
			// Actual error - May cause crash
			LE_ERROR
		} LogEntryType;
		
		// Log entry structure
		typedef struct
		{
			// Entry type
			LogEntryType type;
			// Message of the entry
			std::string message;
			// Local post time
			int tm_hour, tm_min, tm_sec;
			
		} LogEntry;
	
		// Logger class definition
		class Logger
		{
			private:
				// Vector container holding all posted log entries
				std::vector<LogEntry *> m_entries;
		
			public:
				// Default constructor
				Logger();
				// Default destructor
				~Logger();
				
				// Posts a new entry to the logger
				void PostEntry(LogEntryType type, std::string message);
				// Flushes all log entries to a file
				int FlushToFile(const char *fileName);
				// Clears all log entries from the logger object
				void Clear();
		};
	}
}

#endif		// _LOGGER_H
